home *** CD-ROM | disk | FTP | other *** search
- #include "win.h"
-
- void save(work, x, y, x2, y2)
- char *work;
- int x, y, x2, y2;
- {
- struct window *w;
- int sx, sy, sx2, sy2, width;
- extern struct list tail;
- extern void (*blkcpy)(), (*fbread)();
-
- width = x2 - x + 1;
- (*fbread)(work, x, y, width, y2 - y + 1);
- for (w = tail.prev; w->prev != NULL; w=w->prev){
- if (!w->mapped)
- continue;
- sx = max(x, w->x);
- sy = max(y, w->y);
- sx2 = min(x2, w->x2);
- sy2 = min(y2, w->y2);
- if (sx <= sx2 && sy <= sy2 && w->save != NULL)
- (*blkcpy)(w->save, sx - w->x, sy - w->y, w->w,
- work, sx-x, sy-y, width,
- sx2 - sx + 1, sy2 - sy + 1);
- }
- }
-
- void expose(work, w, x, y, x2, y2)
- char *work;
- struct window *w;
- int x, y, x2, y2;
- {
- int width, height;
- extern void _expose();
- extern struct list head;
- extern void (*blkcpy)(), delete();
-
- if ((width = x2 - x + 1) <= 0)
- return;
- if ((height = y2 - y + 1) <= 0)
- return;
- (*blkcpy)(w->save, x - w->x, y - w->y, w->w,
- work, 0, 0, width, width, height);
- delete(w); /* temporary */
- _expose(work, width, x, y, x2, y2, head.next);
- w->prev->next = w;
- w->next->prev = w;
- }
-
- void show(work, w)
- char *work;
- struct window *w;
- {
- extern void _expose();
- extern struct list head;
- extern void (*blkcpy)();
-
- (*blkcpy)(w->save, 0, 0, w->w,
- work, 0, 0, w->w, w->w, w->h);
- _expose(work, w->w, w->x, w->y, w->x2, w->y2, head.next);
- }
-
- void _expose(work, width, x, y, x2, y2, w)
- char *work;
- int width, x, y, x2, y2;
- struct window *w;
- {
- int sx, sy, sx2, sy2, byte;
- extern int pixelsize, fbxmax;
- extern void (*fbwrite)();
-
- for (; w->next != NULL; w = w->next){
- if (!w->mapped)
- continue;
- sx = max(x, w->x);
- sy = max(y, w->y);
- sx2 = min(x2, w->x2);
- sy2 = min(y2, w->y2);
- if (sx <= sx2 && sy <= sy2){
- if (w->save == NULL){ /* don't draw */
- byte = width * pixelsize;
- w = w->next;
- if (y < sy)
- _expose(work, width, x, y, x2, sy-1, w);
- if (x < sx)
- _expose(work+(sy-y)*byte, width, x, sy, sx-1, y2, w);
- if (sx2 < x2)
- _expose(work+(sx2+1-x)*pixelsize,
- width, sx2+1, y, x2, sy2, w);
- if (sy2 < y2)
- _expose(work+(sy2+1-y)*byte, width, x, sy2+1, x2, y2, w);
- return;
- } else
- (*w->draw)(w, work, sx - x, sy - y, width,
- sx - w->x, sy - w->y,
- sx2 - sx + 1, sy2 - sy + 1);
- }
- }
- if (x < 0){
- byte = x2 - 0 + 1;
- work += -x * pixelsize;
- x = 0;
- } else {
- byte = min(x2, fbxmax) - x + 1;
- }
- if (byte >= 0){
- width -= byte;
- (*fbwrite)(work, x, y, byte, y2 - y + 1, width*pixelsize);
- }
- }
-